package com.zhentao.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import lombok.Data;

/**
 * BOM明细表，记录BOM下的物料明细
 * @TableName bom_item
 */
@TableName(value ="bom_item")
@Data
public class BomItem implements Serializable {
    /**
     * 主键ID，明细的唯一标识，用于在系统中唯一确定一条BOM明细记录
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * BOM ID，关联BOM表的ID，表明该明细属于哪个物料清单
     */
    private Long bomId;

    /**
     * 物料ID，关联物料（产品）表的ID，表明该明细涉及的物料
     */
    private Long materialId;

    /**
     * 用量，生产该产品所需该物料的用量
     */
    private BigDecimal quantity;

    /**
     * 工艺，该物料在生产过程中的工艺说明，如加工方法、装配顺序等
     */
    private String process;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        BomItem other = (BomItem) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getBomId() == null ? other.getBomId() == null : this.getBomId().equals(other.getBomId()))
            && (this.getMaterialId() == null ? other.getMaterialId() == null : this.getMaterialId().equals(other.getMaterialId()))
            && (this.getQuantity() == null ? other.getQuantity() == null : this.getQuantity().equals(other.getQuantity()))
            && (this.getProcess() == null ? other.getProcess() == null : this.getProcess().equals(other.getProcess()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getBomId() == null) ? 0 : getBomId().hashCode());
        result = prime * result + ((getMaterialId() == null) ? 0 : getMaterialId().hashCode());
        result = prime * result + ((getQuantity() == null) ? 0 : getQuantity().hashCode());
        result = prime * result + ((getProcess() == null) ? 0 : getProcess().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", bomId=").append(bomId);
        sb.append(", materialId=").append(materialId);
        sb.append(", quantity=").append(quantity);
        sb.append(", process=").append(process);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}